home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / midi / gfft.lha / gfft-2.03 / source / gfft-2.03-source.lha / gmalloc.c < prev    next >
C/C++ Source or Header  |  1996-01-02  |  2KB  |  64 lines

  1. /***************************************************************************
  2.  *          Copyright (C) 1994  Charles P. Peterson                  *
  3.  *         4007 Enchanted Sun, San Antonio, Texas 78244-1254             *
  4.  *              Email: Charles_P_Peterson@fcircus.sat.tx.us                *
  5.  *                                                                         *
  6.  *          This is free software with NO WARRANTY.                  *
  7.  *          See gfft.c, or run program itself, for details.              *
  8.  *              Support is available for a fee.                      *
  9.  ***************************************************************************
  10.  *
  11.  * Program:     gfft--General FFT analysis
  12.  * File:        galloc.c
  13.  * Purpose:     memory allocation
  14.  * Author:      Charles Peterson (CPP)
  15.  * History:     2-June-1993 CPP; Created.
  16.  * Comments:    These are layer(s) on top of malloc and free.
  17.  *              If system doesn't automatically deallocate memory on exit()
  18.  *                special handling could be added here.
  19.  *              If malloc fails, longjmp is called to return to main loop
  20.  *                in gfft, or a more recent setjmp.
  21.  */
  22.  
  23. #include <stdlib.h>
  24. #include "gfft.h"
  25.  
  26. void* gmalloc (unsigned long bytes, int jmp_value)
  27. {
  28.     void *memblock = malloc ((size_t) bytes);
  29.     if (!memblock)
  30.     {
  31.     error_message (OUT_OF_MEMORY);
  32.     RAISE_ERROR (jmp_value);
  33.     }
  34.     return memblock;
  35. }
  36.  
  37. void* grealloc (void *memblock, unsigned long bytes, int jmp_value)
  38. {
  39.     memblock = realloc (memblock, (size_t) bytes);
  40.     if (!memblock)
  41.     {
  42.     error_message (OUT_OF_MEMORY);
  43.     RAISE_ERROR (jmp_value);
  44.     }
  45.     return memblock;
  46. }
  47.  
  48. void* gcalloc (unsigned long n_ele, unsigned long ele_size, int jmp_value)
  49. {
  50.     void *memblock = calloc ((size_t) n_ele, (size_t) ele_size);
  51.     if (!memblock)
  52.     {
  53.     error_message (OUT_OF_MEMORY);
  54.     RAISE_ERROR (jmp_value);
  55.     }
  56.     return memblock;
  57. }
  58.  
  59. void gfree (void* block)
  60. {
  61.     free (block);
  62. }
  63.  
  64.